<?php include('header.php'); ?>
<?php
	$path = explode('/', $_SERVER['REQUEST_URI']);
	$current_post_id =  intval(end($path));
	$post = formatPost($current_post_id);
?>
<div class="container grid">
	<?= get_sidebar() ?>

	<div>
		<h2>
			<a class="nowrap2"><?= $post['title'] ?></a>
		</h2>
		<div class="location">
			<span class="nowrap2"><?= $post['title'] ?></span>
			<span>
				<<
					</span>
					<?php
					$category = get_the_category();
					if (!empty($category)) {
						$typeurl = get_category_link($category[0]->term_id);
						$typename = $category[0]->name;
						echo '<a href="' . esc_url($typeurl) . '" title="' . esc_attr($typename) . '">' . esc_html($typename) . '</a>';
					}
					?>
					<span>
						<<
							</span>
							<a href="/" title="{$web_name}">الصفحة الرئيسية</a>
							<span>الموقع الحالي </span>
		</div>

		<article class="grid mgtb">
			<p><?= $post['date'] ?></p>
			<?= $post['content'] ?>
		</article>

		<h2>
			قراءات ذات صلة
		</h2>
		<section class="grid imgnews">
			<?php
			$random_posts = get_random_posts(8);
			foreach ($random_posts as $post) {
			?>
				<a href="<?= $post['link'] ?>" title="<?= $post['title'] ?>">
					<img src="<?= $post['thumbnail'] ?>" alt="<?= $post['title'] ?>">
					<section class="grid pd">
						<h3 class="nowrap2"><?= $post['title'] ?></h3>
						<span><?= $post['date'] ?> </span>
						<p><?= $post['excerpt'] ?></p>
					</section>
				</a>
			<?php
			}
			?>
		</section>

	</div>
</div>

<?php include('footer.php'); ?>